package ve.ejb.metadata;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author memozac
 */
@Entity
public class ColorimetryStandard implements Serializable {
    private static final long serialVersionUID = 1L;

    public enum Type{CUSTOM,STANDARD};

    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long idColorimetryStandard;

    @ManyToMany(targetEntity=Settings.class) @JoinTable(name="ColorimetryStandardSettings", joinColumns=@JoinColumn(name="idColorimetryStandard"),
    inverseJoinColumns=@JoinColumn(name="idSettings")) private Collection<Settings> settings;

    @ManyToMany(targetEntity=Color.class) @JoinTable(name="ColorimetryStandardColor", joinColumns=@JoinColumn(name="idColorimetryStandard"),
    inverseJoinColumns=@JoinColumn(name="idColor")) private Collection<Color> colors;

    @ManyToOne private ColorimetryScheme colorimetryScheme;

    @Enumerated private Type type;

    @Temporal(value = TemporalType.TIMESTAMP) private Date registerDate;

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }
    
    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public Collection<Color> getColors() {
        return colors;
    }

    public void setColors(Collection<Color> colors) {
        this.colors = colors;
    }

    public ColorimetryScheme getColorimetryScheme() {
        return colorimetryScheme;
    }

    public void setColorimetryScheme(ColorimetryScheme colorimetryScheme) {
        this.colorimetryScheme = colorimetryScheme;
    }

    public Long getIdColorimetryStandard() {
        return idColorimetryStandard;
    }

    public void setIdColorimetryStandard(Long idColorimetryStandard) {
        this.idColorimetryStandard = idColorimetryStandard;
    }

    public Collection<Settings> getSettings() {
        return settings;
    }

    public void setSettings(Collection<Settings> settings) {
        this.settings = settings;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idColorimetryStandard != null ? idColorimetryStandard.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof ColorimetryStandard)) {
            return false;
        }
        ColorimetryStandard other = (ColorimetryStandard) object;
        if ((this.idColorimetryStandard == null && other.idColorimetryStandard != null) || (this.idColorimetryStandard != null && !this.idColorimetryStandard.equals(other.idColorimetryStandard))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.ejb.entity.ColorimetryStandard[id=" + idColorimetryStandard + "]";
    }

}//ends of class
